// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   ShowBalanceDialog.java

package com.boci.clientapp.trading;

import com.boci.clientapp.main.ClientAppLoader;
import com.boci.clientapp.main.TradingClientApp;
import com.boci.clientapp.trading.vo.BalanceSummaryVO;
import com.boci.common.ui.AbstractDialog;
import com.boci.common.util.MessagesConfigurator;
import com.boci.common.util.StringUtil;
import com.boci.common.vo.ResponseVO;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Locale;
import javax.swing.*;
import javax.swing.border.TitledBorder;

public class ShowBalanceDialog extends AbstractDialog
{

    public ShowBalanceDialog(TradingClientApp owner, boolean modal, Locale pLocale)
    {
        super(owner, modal, pLocale, true);
        msgConf = ClientAppLoader.getMessagesConfigurator();
        setSize(500, 215);
        initGUI();
        setText(pLocale);
    }

    private void initGUI()
    {
        getContentPane().setLayout(null);
        getContentPane().setBackground(Color.white);
        panel = new JPanel();
        panel.setBorder(new TitledBorder(null, "", 0, 0, null, null));
        panel.setOpaque(false);
        panel.setBounds(7, 10, 478, 78);
        getContentPane().add(panel);
        lblConsolidated = new JLabel();
        lblConsolidated.setBounds(10, 25, 320, 20);
        lblConsolidated.setHorizontalAlignment(4);
        getContentPane().add(lblConsolidated);
        lblConsolidated2 = new JLabel();
        lblConsolidated2.setBounds(330, 25, 140, 20);
        lblConsolidated2.setHorizontalAlignment(4);
        getContentPane().add(lblConsolidated2);
        lblBuyingPower = new JLabel();
        lblBuyingPower.setBounds(10, 50, 320, 20);
        lblBuyingPower.setHorizontalAlignment(4);
        getContentPane().add(lblBuyingPower);
        lblBuyingPower2 = new JLabel();
        lblBuyingPower2.setBounds(330, 50, 140, 20);
        lblBuyingPower2.setHorizontalAlignment(4);
        getContentPane().add(lblBuyingPower2);
        lblNote = new JLabel();
        lblNote.setHorizontalAlignment(0);
        lblNote.setBackground(new Color(0, 0, 0));
        lblNote.setBounds(0, 95, 489, 20);
        getContentPane().add(lblNote);
        closeButton = new JButton();
        closeButton.setBounds(191, 120, 115, 25);
        closeButton.addActionListener(this);
        getContentPane().add(closeButton);
    }

    public void setText(Locale pLocale)
    {
        super.setText(pLocale);
        currentLocale = pLocale;
        lblConsolidated.setText(msgConf.getUIMessages("SHOW_BALANCE.CONSOLIDATED_BUYING_POWER", pLocale));
        lblBuyingPower.setText(msgConf.getUIMessages("SHOW_BALANCE.BUYING_POWER_QUALIFIED", pLocale));
        lblNote.setText(msgConf.getUIMessages("SHOW_BALANCE.NOTE", pLocale));
        closeButton.setText(msgConf.getUIMessages("SHOW_BALANCE.CLOSE", pLocale));
        setTitle(msgConf.getUIMessages("SHOW_BALANCE.TITLE", pLocale));
        setFont(pLocale);
    }

    private void setFont(Locale pLocale)
    {
        lblConsolidated.setFont(ClientAppLoader.getSmallBoldTextFont(pLocale));
        lblConsolidated2.setFont(ClientAppLoader.getSmallPlainTextFont(pLocale));
        lblBuyingPower.setFont(ClientAppLoader.getSmallBoldTextFont(pLocale));
        lblBuyingPower2.setFont(ClientAppLoader.getSmallPlainTextFont(pLocale));
        lblNote.setFont(ClientAppLoader.getSmallBoldTextFont(pLocale));
        closeButton.setFont(ClientAppLoader.getPlainButtonFont(pLocale));
    }

    public void refresh(ResponseVO pResponseVO)
    {
        if(pResponseVO instanceof BalanceSummaryVO)
        {
            BalanceSummaryVO balanceSummaryVO = (BalanceSummaryVO)pResponseVO;
            String strCurCode = balanceSummaryVO.getCcyCode();
            String strCur = msgConf.getUIMessages(strCurCode, currentLocale);
            String strConBuyPower = StringUtil.formatPriceValue(balanceSummaryVO.getConBuyPower(), strCur);
            lblConsolidated2.setText(strConBuyPower);
            String strBuyPowerQualSec = balanceSummaryVO.getBuyPowerQualSec();
            if(strBuyPowerQualSec == null || strBuyPowerQualSec.length() == 0)
            {
                lblBuyingPower.setVisible(false);
                lblBuyingPower2.setVisible(false);
            } else
            {
                lblBuyingPower.setVisible(true);
                lblBuyingPower2.setVisible(true);
                strBuyPowerQualSec = StringUtil.formatPriceValue(balanceSummaryVO.getBuyPowerQualSec(), strCur);
                lblBuyingPower2.setText(strBuyPowerQualSec);
            }
            setDefFocus();
        }
    }

    public void actionPerformed(ActionEvent e)
    {
        showDialog(false);
    }

    public HashMap getInputValue(String pActionType)
    {
        return null;
    }

    public void setDefFocus()
    {
        SwingUtilities.invokeLater(new Runnable() {

            public void run()
            {
                closeButton.requestFocus();
            }
        }
);
    }

    private JButton closeButton;
    private JLabel lblNote;
    private JPanel panel;
    private JLabel lblConsolidated;
    private JLabel lblConsolidated2;
    private JLabel lblBuyingPower;
    private JLabel lblBuyingPower2;
    private MessagesConfigurator msgConf;
    private Locale currentLocale;

}
